package org.linlinjava.litemall.wx.web;

import org.linlinjava.litemall.core.util.ResponseUtil;
import org.linlinjava.litemall.db.domain.LitemallTopic;
import org.linlinjava.litemall.db.service.LitemallTopicService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/wx/topic")
public class WxTopicController {
    @Autowired
    private LitemallTopicService topicService;

    @PostMapping("/create")
    public Object create(LitemallTopic topic) {
        topicService.create(topic);
        return ResponseUtil.ok();
    }

    @PostMapping("/update")
    public Object update(LitemallTopic topic) {
        topicService.update(topic);
        return ResponseUtil.ok();
    }

    @GetMapping("/list")
    public Object list() {
        return ResponseUtil.okList(topicService.queryList());
    }

    @GetMapping("findOne")
    public Object findById(Integer topicId) {
        return ResponseUtil.ok(topicService.findById(topicId));
    }

}
